EDisCS - the ESO distant cluster survey. Sample definition and optical photometry