Just converted all negative values and kept unsigned char* type to avoid too many modifications in the code.