Preserve file type when creating thumbnails

This prevents the errors we were seeing when trying to create JPEG
thumbnails from indexed color PNGs (JPEG doesn't support indexed color).
Preserving the file type avoids this, and just seems to make sense.

Closes #726