© 2019 CERN, for the CMS Collaboration. Published by the American Physical Society under the terms of the "https://creativecommons.org/licenses/by/4.0/" Creative Commons Attribution 4.0 International license. Further distribution of this work must maintain attribution to the author(s) and the published article's title, journal citation, and DOI. A search for long-lived particles decaying to photons and weakly interacting particles, using proton-proton collision data at s=13 TeV collected by the CMS experiment in 2016-2017 is presented. The data set corresponds to an integrated luminosity of 77.4 fb-1. Results are interpreted in the context of supersymmetry with gauge-mediated supersymmetry breaking, where the neutralino is long-lived and decays to a photon and a gravitino. Limits are presented as a function of the neutralino proper decay length and mass. For neutralino proper decay lengths of 0.1, 1, 10, and 100 m, masses up to 320, 525, 360, and 215 GeV are excluded at 95% confidence level, respectively. We extend the previous best limits in the neutralino proper decay length by up to one order of magnitude, and in the neutralino mass by up to 100 GeV.