image.mk: reduce code duplication, move prepare to a separate make target