Uses libmagic to guess mime type

Since we already depend on libmagic we can stop relying on file extension to
guess the mimetype of the file.