avoid spurious error msg if no image in pdf
remove spurious space in img number

Tell the script that "nbImg" is a number, so that leading/trailing
spaces are removed
minor changes (comments)