changed dowload image logic