Electronic structure and magnetism of La4Ni3O8 from first principles