in reply to Returning jpg works, png NOT
If you run the script on the command line, do you get the binary data of the png printed to your terminal? (you might need to type reset to restore it afterward).