fix binary encoding issues