Made UTF-8 handling more efficient

Tested with JDK 7.0.45