borrow output encoding mucker from Martin Angers