Added better handling of download from s3 to images.