Quality Mask in python