User exif_imagetype (if available) to determine proper file extensions.