Efficient method for the simulation of STM images. I. Generalized Green-function formalism | Synapse