Fixed a bug which prevented layer masks from being properly restored

Also extended the syntax for the saveCanvas() and restoreCanvas()
methods. See the docs for details