Fix THUMBNAIL_PRESERVE_FORMAT with non-ascii filenames.
Git merge master and #202 pull request from