fixed img.free() position