Properly set content type even for errors