Add mask parameter to composite and associated test

This references #212.

GM and IM both take a third optional argument to their composite commands which will be used as a mask. This PR adds that third argument and associated use as well as a corresponding test.