merged evas image masking code from brett