JAVA-1486 fix binary encoding and decoding