Manifestly gauge invariant transition amplitudes and thermal influence functionals in QED and linearized gravity