reorganizing and rescaling images