Change to use writeValueAsBytes