Don't hang forever on message writes.
Buffer the output channel.

Considering before it was effectively infinitely buffering it with
goroutines, having a small explicit (and bounded) buffer would
semantically similar.
Don't hang forever when a connection is closed.
Merge pull request #1 from couchbaselabs/master

Fixed a couple of goroutine leaks.