Improved MIME type detection