The production of isolated photons in PbPb and pp collisions at √sNN = 5.02 TeV