What could the Shah have done to ensure maximum continuity with his policies of the 60s and early 70s and to minimize the chances of revolutionary upheaval in Iran?
I think he should have convinced the US that, after communism, the most important threat to their power is Islamism. That would have maybe made the US support him in the 1979 revolution against the revolutionaries. The same goes with the USSR: he could have approached the USSR and gave them some concessions (for example a naval base on the Indian Ocean), and in turn, the Persian communists could have started to support the Shah by order of Moscow - include the Communists in the single party regime. Then, a joint invasion of Afghanistan by both the Soviets and Persia is possible.
Also, try to improve the living standard of the middle class. The wealth from oil export mostly benefited the Iranian elite and thus strengthened the communist and islamist opposition. Maybe after the White Revolutions of the 60's (women's suffrage, land reform) try to implement a comprehensive social system funded with oil money.
Also, don't force the merchants of the bazaars to enter the single party. Also, From the spring 1978, he stopped to appear in public due to his cancer, which lead to an image of weakness and a power vacuum - avoid this by giving more public responsibility to his son (or his wife, if his son is too young) once he realizes that he's going to die soon.