Isolated photons in deep inelastic scattering and photoproduction