Rebuilt icon mask creation routines.

Mask generation is still a problem.