cleanup write-icon/write-image
fix python3 compatibility