Fix surprising behavior in wire.TxWriter
Fix surprising behavior in wire.TxWriter

In the interest of holding a lock for the absolute shortest amount of
time, originally the `io.WriteCloser` returned from `TxWriter.Tx` did
not actually take the lock until its first `Write`. This had an unintended
side effect. Consider this seemingly innocuous code:

	func encodeMsg(w *wire.TxWriter, header, body []byte) {
		tx := w.Tx()
		defer tx.Close()

		if validHeader(header) {
			tx.Write(header)
			tx.Write(body)
		}
	}

If the lock was only taken on the first write, this function would
call Unlock on a lock it didn't own, causing a run-time panic at
best and ending another transaction prematurely at worst.

This should serve as a reminder that parallel programming is
full of places to make mistakes, and being _correct_ is more
important than being fast, or being clever.

droyo/styx