Generalized method of changing background image