Fix memory leak when drawing images

Signed-off-by: bergerkiller <bergerkiller@gmail.com>