public static String encodeBytes(byte[] source)
	{
		int off = 0;
		int len = source.length;

		int len43 = len * 4 / 3;
		byte[] outBuff = new byte[(len43) // Main 4:3
				+ ((len % 3) > 0 ? 4 : 0)]; // Account for padding
		int d = 0;
		int e = 0;
		int len2 = len - 2;
		for (; d < len2; d += 3, e += 4)
			encode3to4(source, d + off, 3, outBuff, e);

		if (d < len)
		{
			encode3to4(source, d + off, len - d, outBuff, e);
			e += 4;
		}

		// Return value according to relevant encoding.
		try
		{
			return new String(outBuff, 0, e, PREFERRED_ENCODING);
		}
		catch (java.io.UnsupportedEncodingException uue)
		{
			return new String(outBuff, 0, e);
		}
	}