Fix/codec encode context

this fixes #1523 
@x?