update create_virtualimage script
copied changes from #34854f9 and #467914e.