Change write_json from 'wb' to 'w' in posts_controller