util functions to convert StdGen to Integer and back

Needed for #77.