Improved Javascript encoder speed