Try to minimize the number of masks required.

make_grid_markup now searches over x and y offsets for the masks
in order to find the minimum number of masks which will cover the
markup.