improved handling of lakes mask computation