Transfer formalism for quantum optics problems