PDFBOX-1694, PDFBOX-1696: fixed a padding issue, added some optimizations based on a proposal by Tilman Hausherr

git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1517273 13f79535-47bb-0310-9956-ffa450edef68