Photocatalytic and electrocatalytic reduction of CO2 to CO