By default, the 'mask' option essentially says the masking colour is transparent. Transparent pixels are skipped, and those furthest away (non-transparent), are drawn upon.
This should be changed to also allow a 'masking colour'. The colours furthest away from the masking colour will be changed, and those closest will not.
This is so you can shade areas, on an image which already has a background present.