static public byte[] encode(byte[] in)
	{
		byte[] out = new byte[20000];
		int i, j, bitat, outlen, firstByte;
		long t;
		bitat = 0;
		for(i = 0;i < in.length;i++)
		{
			t = huffLookup[unsigned(in[i])].bits;
			for(j = 0;j < huffLookup[unsigned(in[i])].len;j++)
			{
				putBit(out, bitat + huffLookup[unsigned(in[i])].len - j - 1, t&1);
				t >>= 1;
			}
			bitat += huffLookup[unsigned(in[i])].len;
		}
		outlen = 1 + (bitat+7)/8;
		firstByte = 8*(outlen-1) - bitat;
		if(outlen >= in.length+1)
		{
			byte[] returnVal = new byte[in.length+1];
			returnVal[0] = (byte) 0xFF;
			for(int k = 0;k < in.length;k++)
			{
				returnVal[k+1] = in[k];
			}
			return returnVal;
		}
		byte[] returnVal = new byte[outlen];
		returnVal[0] = (byte) firstByte;
		for(int k = 0;k < outlen-1;k++)
		{
			returnVal[k+1] = out[k];
		}
		return returnVal;
	}