Re-factored image upload