Let $k$ be a field, $\overline{k}$ its algebraic closure. Suppose $X$ is an algebraic variety over $\overline{k}$. This means that $X$ is a scheme with a finite covering by open affine varieties over $\overline{k}$. The definition i'm using for an affine variety is that it is isomorphic to $SpecA$ for $A$ finitely generated over $\overline{k}$.
I am trying to prove that there exists a finite extension $k'$ of $k$, and an algebraic variety $Y$ over $k'$ such that the base change $Y_{\overline{k}}$ is isomorphic to $X$. I have managed to prove this for the case that $X$ is affine, since then $X \cong Spec(\overline{k}[x_1, ..., x_n]/I)$ for some finitely generated ideal $I$. If $I$ is generated by $f_1, ..., f_r$, we can simply add their coefficients to $k$ to get $k'$, and define $Y := Spec(k'[x_1, ...,x_n]/I')$, with $I'$ generated by $f_1, ..., f_r$ over $k'$.
I am having some trouble passing to the general case $X = X_1 \cup ... \cup X_l$ a finite union of affine varieties. For simplicity I am trying to prove first for $X = X_1 \cup X_2$, and suppose $X_1 = Spec(\overline{k}[x_1, ..., x_n]/I_1), X_2 = Spec(\overline{k}[y_1, ..., y_m]/I_2)$.
What i've done so far: Denote $X_1 \cap X_2$ by $D(J_1)$ when viewed as an open subvariety of $X_1$, and $D(J_2)$ when viewed as an open subvariety of $X_2$. I know that the intersection of open affine varieties is affine, hence $D(J_1), D(J_2)$ are affine.
It is then possible to define $k'$ by adding to $k$ all the coefficients of the generators of $I_1, I_2, J_1, J_2$, and as above define $Y_1, Y_2$, and even $D(J'_1) \subset Y_1$, $D(J'_2) \subset Y_2$ with $D(J'_1)_{\overline{k}} = D(J_1) \cong D(J_2) = D(J'_2)_{\overline{k}}$. However, in order to glue $Y_1$ and $Y_2$ together, I need to prove that $D(J'_1) \cong D(J'_2)$, and this is where I am rather stuck. I am not even sure how to construct an "induced" morphism between them.
So my question is - How to construct $Y$? Am I in the right direction? Is there another appealing way to tackle this?
Thanks very much in advance.