code: public static byte[] encode_long(BigInteger big) {
  		byte[] data=big.toByteArray();
  		// reverse the byte array because pickle uses little endian
  		byte[] data2=new byte[data.length];
  		for (int i = 0; i < data.length; ++i)
  			data2[data.length - i - 1] = data[i];
  		return data2;
  	}
docs: encode an arbitrary long number into a byte array (little endian).