Handle some nasty cases where a layer with a mask extends beyond the canvas #45