fixed image handling bug