improve imagep(): issue 312