Measuring cosmic distances with galaxy clusters