Fix IndexOutOfBoundsException raised by JZlibEncoder.encode()

- Fixes #1471