The star formation region NGC 6530: Distance, ages and initial mass function