Make reentrant, threadsafe: add state object to hold state
encode: use local temporaries to avoid cache thrashing

This gives a >10% speed improvement in our benchmark.
decode: use local temporaries to avoid cache thrashing
Test: add test for stream en/decoding with different blocksizes