Compression fixes

For some reason the streams only flush if you put them inside "using"
blocks. I've tried not to do too much cargo cult copy 'n' paste, will
revisits this code later