Only include data from the valid range of a BytesWritable

Change-Id: Iab2a04bba06597d1df2d2d2dfb7059faa0d2b725