More robust argument validation in createImage