More efficient image validation