Use mimetypes module rather than try to implement our own

I typed this directly on github, I hope it's fine.