HTML5 canvas G-Mask implementation