Javascript JPEG Encoding