Improve network writing.

Using NetworkStream.WriteByte() results in multiple TCP packets being
sent per MQTT packet, which is very inefficient. This commit uses a
MemoryStream to amalgamate the whole MQTT packet, then writes it to the
NetworkStream.