Added a null check to toBase64String and cleaned up Javadoc.