Use mimetypes module instead of random hacks to detect mimetypes