QCD duality and the mass of the charm quark