Accurate photometric redshifts for the CFHT legacy survey calibrated using the VIMOS VLT deep survey