write packets as a single write()

Rather than multiple writes to the socket from different buffers I'm now
writing into a single bytes.Buffer then writing that whole buffer to
the socket, I thought the previous way was causing problems with an
mqtt server and there is no equivalent to writev() in Go.