The rational parts of one-loop QCD amplitudes I: The general formalism