refactor subsampling code
fill remaining bits in last block in the bitstream