move the dimW, dimH error checks earlier

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>