correctly encode control chars; fixes #16