Don't save/restore the canvas state too often. Fixes #703