reverted recent changes due to encode is not continuous in terms of subsequent calls (leaving header byte holes)