some refactoring to support streamed reading, including using gzip.GzipFile instead of zlib; fixes (unexplained) issues with last commit