imagep() imrpovements for issue 372