Use Java 7 auto resource management

More concise than try/catch with a manual call to close()
Add minimum chunkSize constraint

Chunks are prefixed with a 12 byte header, so the smallest possible
chunk is 13 bytes.
Tidy up chunking/sending algorithm

Now generates and sends chunks in a single pass. Algorithm is also more
intelligible.