There are several ways I would recommend depending on which axis of efficiency you are wanting (bandwidth vs CPU efficiency).
Option 1: You can use the canvas toDataURL method. This returns a base64 encoded image of the canvas image data. It will be compressed using the image format you specify (or PNG for the default) and it will be pre-encoded to base64 for sending over WebSocket.
canvas = document.getElementById("mycanvas");
b64png = canvas.toDataURL();
ws.send(b64png);
Option 2: If you can tolerate lossy compression then you can ask for the image as a base64 encoded JPEG from the toDataURL method:
canvas = document.getElementById("mycanvas");
b64jpeg = canvas.toDataURL("image/jpeg");
ws.send(b64jpeg);
Option 3: If you are using a browser that supports binary WebSocket data (Chrome, Firefox, IE 10) then you can just send the canvas arraybuffer directly over WebSocket
canvas = document.getElementById("mycanvas");
ctx = canvas.getContext('2d');
imgdata = ctx.getImageData(0,0, width, height).data; // This is a Uint8ClampedArray
ws.send(imgdata.buffer); // Send the ArrayBuffer from the Uint8ClampedArray
Option 3 will likely be the least efficient in terms of bandwidth, but the most efficient in terms of processing power on the client and server side because the image data is sent raw with little pre/post processing required.
The most bandwidth efficient option will likely be #2 but you will lose some image quality during conversion of the image data to JPEG format. You could even go further and base64 decode the data into an arraybuffer or blob and send that via binary WebSocket so that you don't get the 33% base64 bandwidth overhead, but this adds even more CPU overhead.
If you want efficient bandwidth without losing any image quality then option #2 is your best bet.
Some notes/caveats:
The toDataURL prefixes the base64 data something like this:
"data:image/png;base64,iVBORw0KGgoAAAA..."
One nice thing about the data URL format is that you can take the whole thing and paste it into your browsers address bar and the browser will render the image.
See the MDN Canvas page for more info about toDataURL.