A paedophile who had a stash of images of children “in visible pain and distress” as well as a slew of sick messages on his phone has avoided prison.