Fix bugs in WebSocket writeMessage

Signed-off-by: Julien Viet <julien@julienviet.com>
by expert I mean you or Norman.