Photochemically-produced SO$_2$ in the atmosphere of WASP-39b