Added function to generate a UIImage from a view