general mask rgb implementation