In ChunkFile, don't switch on the mode for every byte. The compiler can't optimize it away because of the potential for aliasing, so it ends up pretty gross.