be ready for large keys: DataOutputStream.writeUTF schokes on strings larger than 0xFFFF
(cherry picked from commit 4e65421) (r=Peter.Gromov)