The string-based Bern-Kosower rules provide an efficient way for obtaining
parameter integral representations of the one-loop N - photon/gluon amplitudes
involving a scalar, spinor or gluon loop, starting from a master formula and
using a certain integration-by-parts (`IBP') procedure. Strassler observed that
this algorithm also relates to gauge invariance, since it leads to the
absorption of polarization vectors into field strength tensors. Here we present
a systematic IBP algorithm that works for arbitrary N and leads to an integrand
that is not only suitable for the application of the Bern-Kosower rules but
also optimized with respect to gauge invariance. In the photon case this means
manifest transversality at the integrand level, in the gluon case that a form
factor decomposition of the amplitude into transversal and longitudinal parts
is generated naturally by the IBP, without the necessity to consider the
nonabelian Ward identities. Our algorithm is valid off-shell, and provides an
extremely efficient way of calculating the one-loop one-particle-irreducible
off-shell Green's functions (`vertices') in QCD. It can also be applied
essentially unchanged to the one-loop gauge boson amplitudes in open string
theory. In the abelian case, we study the systematics of the IBP also for the
practically important case of the one-loop N - photon amplitudes in a constant
field.Comment: 27 pages, no figures, v2 corrects typos in eqs. (3.7) and (4.11