The gradient flow at higher orders in perturbation theory