Fix/codec encode context

this fixes #1523