use buffer.readSlice(length) to minimize memory copies