Use context manager for gzipfile
Use built-in werkzeug method for response length calculation