improved mime type handling