in reply to Re: Returning jpg works, png NOT
in thread Returning jpg works, png NOT

Good catch! That, in fact, could explain the symptoms, because the magic bytes of the PNG format ("\x89PNG\r\n\cz\n") is specifically designed such that it becomes corrupted if you mess up line endings, whereas a small jpg image might not contain "\r\n" anywhere at all so it may survive being read in text mode.