Only include data from the valid range of a BytesWritable

Change-Id: I51440d5c1f395625ad815510e6785211c698e6af