Fix unsafe usage of FileChannel.read()

`read()` may return fewer bytes than requested; when this occurred, the old
code would silently return less data than requested, which might cause stream
corruption errors.
@haoyuan In addition to improper use of `read()`, I think this code function could have potentially returned `Some(null)` when `is == null` (which should never happen, but still...).

Can you verify that these changes are correct?