Implements serialisation of return data.

Resolves #11.