fix up gzip writing