The UV galaxy luminosity function at z = 3–5 from the CFHT Legacy Survey Deep fields