You're going to need to do some server side PHP processing for this, but that's fine, because Wordpress uses PHP.
Something like this should do it:
<?php
// send.php, place in wordpress root
$dir = getcwd(); // get the current working directory
$now = date("U"); // create a timestamp to append to the filename
$imgstring = $_POST['data'];
$imgstring = base64_decode($imgstring);
file_put_contents("$dir/wp-content/uploads/image-$now.png", $imgstring);
?>
And in your javascript:
function sendtowordpress()
{
dataUrl = canvas.toDataURL("image/png");
dataUrl = dataUrl.replace(/^data:image\/(png|jpg);base64,/, "");
$.post("send.php?data="+dataUrl);
}