improve image validation