changed gzip writes to synchronous; fixed bug in .gz detection.