Translating what CPallini told in the other answer...
You can translate decimal to binary manually too:
25 / 2 = 12, rest = 1
12 / 2 = 6, rest = 0
6 / 2 = 3, rest = 0
3 / 2 = 1, rest = 1
Now you just have to go backwards with the results and you get the binary 11001
Another example: 147
147 / 2 = 73, rest = 1
73 / 2 = 36, rest = 1
36 / 2 = 18, rest = 0
18 / 2 = 9, rest = 0
9 / 2 = 4, rest = 1
4 / 2 = 2, rest = 0
2 / 2 = 1, rest = 0
gives you: 10010011
Now you can try to implement it in the specific language of your needs
note: this will always give you the binary until the first representative 1, if you want to have them grouped in bytes (with zeros filling the left side) you have to do it yourself counting how many "digits" do you get and filling them by hand