in reply to Downloading and saving images.

Try this after the call to open() and before the print:
binmode outfile;