Use os.urandom() to read from /dev/urandom

Use os.urandom() instead of f.read(n), so that we really read only n bytes, not 4kB.