fix bug in content type when throwing 500 error, add mimehandler class to deal better with mimetypes, support also JSON