Fix buffer overflow in R_UploadImage