Use only one temp canvas for patterns

This fixes a regression #3153 which was introduced by #2177.
The temp vanvases that are being created are not being re-used, which lead
to high memory use.

Instead of creating multiple temporary canvases, we have only one temp canvas. Only the size of the canvas changes. Also a pattern id no longer pre-created, instead it is created when the pattern is really needed.

In my system the memory use was much lower with the patch.