We show that a single imperfect fluid can be used as a source to obtain the generalized McVittie metric as an exact solution to Einsteins equations. The mass parameter in this metric varies with time thanks to a mechanism based on the presence of a temperature gradient. This fully dynamical solution is interpreted as an accreting black hole in an expanding universe if the metric asymptotes to Schwarzschild-de Sitter at temporal infinity. We present a simple but instructive example for the mass function and briefly discuss the structure of the apparent horizons and the past singularity.