better error handling, default mime type