Write encoder method