MaskImageIn(), MaskImageOut() - Make it actually work.

This was untested and entirely broken since day 1!
Hopefully fixes issue #109