Fixed packets not writing to byte stream correctly