Use ByteBuffer to avoid encoding errors on collections

Closes #100.