The gas distribution in the outer regions of galaxy clusters