Put mask data to the canvas in small slices.

In pull #4138, I changed image drawing to be in small chunks, to avoid creating large copies of the image data.

This patch does the same thing for image masks. I have two test documents that use masks, which I test by scrolling through the whole document and measuring peak RSS. The improvements were:

- ~380 to ~290 MiB
- ~370 to ~260 MiB