Hybrid photometric redshifts for sources in the COSMOS and XMM-LSS fields