Fixed writing bytes repeating more than 255 times