To save the image on the server you have to get the image data from the painter and send it to ther server.
You can get the image data using the painter method
var imageData = painter.getImageData();
Then you can send the obtained string to the server using a hidden field in an HTML form or using AJAX.
Your server-side script will have to decode the data and convert it to binary image file (if necessary) or save it on the server as is.