Use a mask from a layer called "mask" if it exists

Otherwise, just use the result of merging the visible layers as before