code: @Override
    public void writeBytes(byte[] bytes, int start, int len) throws IOException {
      for (int i = start; i < start + len; ++i) {
        if (bytes[i] == 0x00) {
          out.write(0);
          out.write(1);
        } else {
          out.write((int) bytes[i]);
        }
      }
      out.write(0);
      out.write(0);
    }
docs: Bytes are encoded by writing all bytes out as themselves, except for bytes
  of value 0x00. Bytes of value 0x00 are encoded as two bytes, 0x00 0x01. The
  end marker is signified by two 0x00 bytes. This guarantees that the end
  marker is the least possible value.
  
  @param bytes
  The bytes to encode.
  @param start
  The start of the byte array to encode.
  @param len
  The length of the byte array to encode.