Distances and ages of NGC 6397, NGC 6752 and 47 Tuc