Rewrite BytesStreamOutput on top of BigArrays/ByteArray.

Fix for #5159