Generalise to allow serialising from/to any DataInput/DataOutput.
Merge branch 'data-input-output'