add EncodeStream and tests