fix #309 when THUMBNAIL_PRESERVE_FORMAT=True and remote images
Merge pull request #310 from mgaitan/fix309

fix #309, fix _get_format for images with urls