make preprocess_images generalized