The general algorithm for changing a number n to base b goes something like:
i = 0
while(n != 0)
answer[i] = n mod b
n /= b
i++
(Note that answer[0] holds the least significant digit of the answer.) Does this make sense? Which part of this pseudocode are you having trouble implementing?