factor out transform-block encoding