improved file handling and mime type handling for responses