Fix THUMBNAIL_PRESERVE_FORMAT with non-ascii filenames.

I added support for non-ascii filenames in the THUMBNAIL_PRESERVE_FORMAT path.  I also wrote some tests to test the `_get_format` method.

It was kinda hard to do the tests though, the settings thing gets in the way of using `override_settings` if you have suggestions as to how to go about that I'd be willing to rework this.