checking invalid image buffer