Use 512 as a max pattern size

This fixes a regression #3153 which was introduced by #2177.
Having too large MAX_PATTERN_SIZE causes huge pixmaps to be created
that will lead to OOM.