This method improves the performance of encoding/decoding archives by avoiding unnecessary copies of data in memory (thanks to BrainStackOverFlow for this suggestion).
For 256 MB archives, decoding is now 40x faster, and encoding is about 6-7x faster. The bigger the archive, the greater the speedup.
In addition, decode_stream and encode_stream functions were added. This allows archives to be decoded without loading the entire archive into memory.