Add function to preprocess images