  We show that the properties of the electron beam and bright x-rays produced
by a laser wakefield accelerator can be predicted if the distance over which
the laser self-focuses and compresses prior to self-injection is taken into
account. A model based on oscillations of the beam inside a plasma bubble shows
that performance is optimised when the plasma length is matched to the laser
depletion length. With a 200~TW laser pulse this results in an x-ray beam with
median photon energy of \unit[20]{keV}, $> 6\times 10^{8}$ photons above
\unit[1]{keV} per shot and a peak brightness of $\unit[3 \times
10^{22}]{photons~s^{-1}mrad^{-2}mm^{-2} (0.1\% BW)^{-1}}$.
