Maybe I miss an important point, but the reason for the bug described in #597 was that, `guess_encoding` provided the mime type rather than the encoding. I only moved the mime_type code to where it belongs: `guess_mimetype`. `guess_encoding` now returns the actual guessed file encoding.