In the following link you can find a script to convert any number into a 2 dimensional pattern. The details about the implementation are here.