added mean and std methods that take mask into account