avoid array copy unless necessary, to improve performance

When `read == chunkSize` (which should be the case until the end of the file), there's no need to allocate and copy into another bytearray, we can just return `buffer`. Should improve performance of fromStream().