You shouldn't add the layer
to the stage
every time an image is added. What you should do is:
layer.add(new_image);
layer.draw(); //draws the new image added to the layer
Also, your toDataURL
method looks correct, in fact it looks exactly like this tutorial if you haven't checked it out yet.