Fix bugs in WebSocket writeMessage

Signed-off-by: Julien Viet <julien@julienviet.com>