Image upload helper refactured