better MIME magic library handling

The different mime magic libraries expect input to their from_file(),
file(), and id_filename() functions, respectively, to take either a
filesystem-encoded (generally UTF-8) string, or a unicode filename.
Different versions of the libraries each expect different inputs for
filename though.  This is annoying.

Here, we call these functions, first with a UTF-8 encoded string
filename.  If that fails with a UnicodeDecodeError, we try again
passing a unicode filename.

Also, delete mime_magic_buffer() everywhere, and the introspection of
gzip files to see what type of object is inside.  It doesn't matter to
the S3 web server - it needs to be type application/x-gzip, not
type=application/tar encoding=gzip (as mimetypes would tell us). We
stopped using the encoding value here as HTTP Content-Encoding in
commit 44e35899a anyhow.