NCBC-633: Make TypeSerializer use ToArray instead of GetBuffer

GetBuffer returns the entire buffer whether it was written to or not; this
causes issues with the server side translation of JSON turing it into a
binary blob. ToArray only takes the portion of the buffer that has been written to.

Change-Id: I72f61758b61113a3a249f793f8fa0b9535dc68d9
Reviewed-on: http://review.couchbase.org/41284
Tested-by: Jeffry Morris <jeffrymorris@gmail.com>
Reviewed-by: Brett Lawson <brett19@gmail.com>