Set max buffer to Math.pow(2,19)

Fix #761