added optional commons-codec dependency

there are some platforms (e.g. android) that do not have by default the java.xml.bind package. The solution is to use the commons-codec implementation if it's on the classpath and fallback to java.xml.bind
merged in recent changes from pablos repo. added changes to make it work for android