Fix invalid image bug