finished arbitrary base conversion function