Fix THUMBNAIL_PRESERVE_FORMAT with non-ascii filenames.