Fix error when mask is a boolean array