improve image handling