small changes from JC's script including download of a  mask layer