Ensure byte arrays are read fully.

This patch reads bytes into byte arrays taking into account that a call to InputStream.read(byte[] b) may not fully populate the byte array.  The return value must be checked to determine how many bytes were actually
read.  This fixes a problem that I actually encountered in the field.  I wish Java just blocked until it had all the bytes, but unfortunately, this is how it behaves.